:<template>
	<view>
		<view style="height: 4rpx;background-color: #F5F5F4;" class="mt-2"></view>
		<text class="example-info">热门搜索</text>
		<view class="example-body">
			<view class="tag-view" @click="hotSearhAction(index)"
			v-for="(item,index) in hostlist" :key="index" >
			<uni-tag :circle="false" :text="item.name" />
			</view>
		</view>
		<text class="example-info">搜索历史</text>
		<view class="example-body">
			<view class="tag-view" @click="historySearhAction(index)"
			v-for="(item,index) in historylist" :key="index">
			<uni-tag :circle="false" :text="item.name" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				type: 'default',
				inverted: false,
				hostlist: [{
					name: "张娟"
				}, {
					name: "戴花"
				},{
					name: "经济纠纷"
				},{
					name: "合同"
				},{
					name: "交通"
				},{
					name: "酒驾"
				},{
					name: "刑事案件"
				},{
					name: "劳动争议"
				},{
					name: "财产纠纷"
				},{
					name: "企业"
				}],
				historylist: [{
					name: "企业"
				}, {
					name: "单方面违约"
				},{
					name: "公司倒闭不给钱."
				},{
					name: "违法"
				},{
					name: "公司法"
				},{
					name: "财产纠纷"
				},{
					name: "美食"
				},{
					name: "抚养权"
				},{
					name: "财产纠纷"
				},{
					name: "交通"
				}],
			};
		},
		onLoad() {
			// 初始化
			// console.log("onLoad");
		},
		methods: {
			setType() {
				let types = ['default', 'primary', 'success', 'warning', 'error'];
				let index = types.indexOf(this.type);
				types.splice(index, 1);
				let randomIndex = Math.floor(Math.random() * 4);
				this.type = types[randomIndex];
			},
			setInverted() {
				this.inverted = !this.inverted;
			},
			// 切换选项卡
			hotSearhAction(index) {
				uni.navigateTo({
					url: '../search-out/search-out?result='+JSON.stringify(this.hostlist[index]),
				});
				console.log(this.hostlist[index]);
			},
			historySearhAction(index) {
				uni.navigateTo({
					url: '../search-out/search-out?result='+JSON.stringify(this.historylist[index]),
				})
			},
		}
	};
</script>

<style>
	@charset "UTF-8";

	/* 头条小程序组件内不能引入字体 */
	/* #ifdef MP-TOUTIAO */
	@font-face {
		font-family: uniicons;
		font-weight: normal;
		font-style: normal;
		src: url("~@/static/uni.ttf") format("truetype");
	}

	/* #endif */
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #FFFFFF;
		min-height: 100%;
		height: auto;
	}

	view {
		font-size: 14px;
		line-height: inherit;
	}

	.example {
		padding: 0 15px 15px;
	}

	.example-info {
		padding: 15px;
		color: #3b4144;
		background: #ffffff;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		padding: 0;
		font-size: 14px;
		background-color: #ffffff;
	}

	/* #endif */
	.example {
		padding: 0 15px;
	}

	.example-info {
		text-align:left;
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding:15px 15px 0;
		color: #000;
		background-color: #ffffff;
		font-size: 14px;
		line-height: 20px;
	}

	.example-info-text {
		font-size: 14px;
		line-height: 20px;
		color: #3b4144;
	}

	.example-body {
		flex-direction: column;
		padding: 15px;
		background-color: #ffffff;
	}

	.word-btn-white {
		font-size: 18px;
		color: #FFFFFF;
	}

	.word-btn {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		border-radius: 6px;
		height: 48px;
		margin: 15px;
		background-color: #007AFF;
	}

	.word-btn--hover {
		background-color: #4ca2ff;
	}

	.example-body {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: flex-start;
		flex-wrap: wrap;
		padding: 20rpx;
	}

	.tag-view {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		margin: 10rpx 15rpx;
		justify-content: center;
	}
</style>